﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.RoleCommand;
using MediatR;
using Org.BouncyCastle.Asn1.Ocsp;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.RoleCommandHandler
{
    public class DeleteRoleCommandHandler : IRequestHandler<DeleteRoleCommand, Results<int>>
    {
        private readonly IRoleService _roleService;
        public DeleteRoleCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        async Task<Results<int>> IRequestHandler<DeleteRoleCommand, Results<int>>.Handle(DeleteRoleCommand request, CancellationToken cancellationToken)
        {
            int n = await _roleService.DeleteRole(request.Id);
            return Results<int>.DataResult(n);
        }
    }
}
